/**
 * Created by Administrator on 2017/1/12.
 */

//第三种兼容
define('nav',function () {
    var EventUtil = {
        addHandler: function (oElement, sEvent, fnHandler) {  //sevent不带on
            oElement.addEventListener ? oElement.addEventListener(sEvent, fnHandler, false) : oElement.attachEvent("on" + sEvent, fnHandler)
        },
        removeHandler: function (oElement, sEvent, fnHandler) {
            oElement.removeEventListener ? oElement.removeEventListener(sEvent, fnHandler, false) : oElement.detachEvent("on" + sEvent, fnHandler)
        },
        addLoadHandler: function (fnHandler) {
            this.addHandler(window, "load", fnHandler)
        }
    };
})
// 加载模块
module.exports = function(ngModule) {
    require('./header-nav.scss');
    ngModule.directive('headerNav',function () {
        return {
            restrict: 'E',//元素(element)
            scope: {},
            replace: true,
            template: require('./header-nav.html'),//模板
            controllerAs: 'header-nav',// <=> $scope.vm = {greeting: '你好，我是卡哥'}
            controller: function () {
            }
        }
    });//定义指令，对应页面中的<hello-world></hello-world>
    require(['nav'], function (my){
        var $ = require('jquery');
        $(".item").each(function () {
            if($(this).attr("data-url")==sessionStorage.pages){
                $(this).addClass("san")
            }
        })
        $(".item").click(function () {
            sessionStorage.setItem("pages",$(this).attr("data-url"))
            location.href=location.origin+"/webpack/src/pages"+$(this).attr("data-url")
        })

    });
}

